feat(agent): route selected products to the ai-gateway - #3659
feat(agent): route selected products to the ai-gateway#3659brandonleung wants to merge 3 commits into
Conversation
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015gyKxP2MuVuNRCK9uZt1Lr
|
Merging to
After your PR is submitted to the merge queue, this comment will be automatically updated with its status. If the PR fails, failure details will also be posted here |
|
React Doctor found no issues in the changed files. 🎉 Reviewed by React Doctor for commit |
|
Reviews (1): Last reviewed commit: "feat(agent): route selected products to ..." | Re-trigger Greptile |
…sertion Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015gyKxP2MuVuNRCK9uZt1Lr
richardsolomou
left a comment
There was a problem hiding this comment.
would be worth testing exact 8,192-byte and 8,193-byte blobs so an off-by-one at the gateway limit cant slip through
|
👋 Visual changes detected for this PR. Review and approve in PostHog Visual Review If these changes are unexpected, they may be caused by a flaky test or a broken snapshot on master. Don't approve — rerun the job or wait for a fix. |
Problem
Model calls from code sandboxes all go through the legacy Python
llm-gateway. We're migrating products to the new Goai-gatewayone at a time, so the agent-server needs to pick a gateway per request. The two gateways also take attribution differently: the old one wants a product slug in the URL plus per-property headers, the new one wants a single JSON header.Changes
Routing to the new gateway is opt-in via two env vars:
AI_GATEWAY_URLis the new gateway's address;AI_GATEWAY_PRODUCTSlists theai_productvalues that may use it. Both must be set. Unlisted products keep using the Python gateway.ai_product,ai_stage, andteam_idin oneX-PostHog-Propertiesheader, built by a newbuildPosthogPropertiesBlobhelper in@posthog/shared(enforces the gateway's 8KB / ASCII limits).ai_producttags (signals_scout, ...), matching the non-sandbox signals stages.How did you test this?
Unit tests cover the routing choice and the header builder (cap trimming, sanitization, unlisted products falling back).
tscandbiomeclean.Inert until the sandbox chart sets both env vars (PostHog/posthog#72770 plus a charts PR). Rollback: clear either one.